using System;
using System.Collections.Generic;
using System.Text;
using MessageReader;

namespace MessageReader
{
    class Unitest
    {
        static void Main() {
            MessageReader mr = new MessageReader();
            Message msg = mr.DecipherMessage();

            if (msg.Type != Message.MessageType.MSG_EMPTY) {
                System.Console.Out.WriteLine("Failed.");
                return;
            }

            mr = new MessageReader("This is a bad message");
            msg = mr.DecipherMessage();
            if (msg.Type != Message.MessageType.MSG_BAD) {
                System.Console.Out.WriteLine("Failed.");
                return;
            }

            mr = new MessageReader("#Bad Message Body");
            msg = mr.DecipherMessage();
            if (msg.Type != Message.MessageType.MSG_BAD) {   
                System.Console.Out.WriteLine("Failed.");
                return;
            }

            mr = new MessageReader("#" + Message.MessageType.MSG_CAR.ToString() + "#this is a good car message");
            msg = mr.DecipherMessage();
            if (msg.Type != Message.MessageType.MSG_CAR || msg.Contents != "this is a good car message") {
                System.Console.Out.WriteLine("Failed.");
                return;
            }

            mr = new MessageReader("#" + Message.MessageType.MSG_PARKINGLOT.ToString() + "#this is a good parking lot message");
            msg = mr.DecipherMessage();
            if (msg.Type != Message.MessageType.MSG_PARKINGLOT || msg.Contents != "this is a good parking lot message") {
                System.Console.Out.WriteLine("Failed.");
                return;
            }

            System.Console.Out.WriteLine("Succeeded.");
        }
    }
}
